home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 10744 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: kbad.eglin.af.mil!rpi!not-for-mail
  2. From: league@cs.UMD.EDU (Christopher League)
  3. Newsgroups: comp.lang.c++,comp.lang.c++.moderated
  4. Subject: Re: Enumerated type converted to pointer? Legal?
  5. Date: 9 Mar 1996 21:09:28 -0000
  6. Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742
  7. Sender: cppmods@netlab.cs.rpi.edu
  8. Approved: Dietmar.Kuehl@uni-konstanz.de
  9. Message-ID: <4hss28$4mj@netlab.cs.rpi.edu>
  10. References: <4hobji$mco@netlab.cs.rpi.edu>
  11. NNTP-Posting-Host: netlab.cs.rpi.edu
  12. X-Original-Date: 08 Mar 1996 17:26:08 GMT
  13.  
  14. {I stripped 'comp.std.c++' from the list of newsgroups: Please do NOT
  15. crosspost to other (moderated) newsgroups... -mod}
  16.  
  17. In article <4hobji$mco@netlab.cs.rpi.edu> bstowers@pobox.com (Brad
  18. Stowers) writes:
  19. >
  20. >   typedef enum { mdType1, mdType2, mdType3 } myType;
  21. >
  22. >   void FooBar(int x, int* y, myType type = mdType1);
  23. >
  24. >   main()
  25. >   {
  26. >     int x = 10;
  27. >     int* y = &x;
  28. >     FooBar(x, y, mdType2);
  29. >     FooBar(x, mdType1);
  30. >   }           ^^^^^^^^^^^^^ should be a type error.
  31. >
  32.  
  33. I think it definitely *should* be a type error, ESPECIALLY in the
  34. latest ANSI/ISO draft, in which functions can now be overloaded based
  35. solely on enumerated types.  (i.e.-- (enum == int) no more).
  36.  
  37. >I have verified that this happens on both Borland and Symantec compilers.
  38. >Can anyone verify it on Watcom and Microsoft for me?
  39.  
  40. In the Unix world, g++ says
  41.     foo.c: In function `int  main ()':
  42.     foo.c:17: incompatible types in argument passing
  43.  
  44. But then, GNU is *usually* well ahead of the big PC compiler vendors
  45. on these things... (does Borland have 'bool' yet?)
  46.  
  47. `Chris
  48. _____
  49. Christopher League            league@cs.umd.edu
  50. University of Maryland            http://www.cs.umd.edu/users/league
  51. Department of Computer Science        PGP Public Key available
  52.  
  53.       [ Articles to moderate: mailto:c++-submit@netlab.cs.rpi.edu ]
  54.       [  Read the C++ FAQ: http://www.connobj.com/cpp/cppfaq.htm  ]
  55.       [  Moderation policy: http://www.connobj.com/cpp/guide.htm  ]
  56.       [      Comments? mailto:c++-request@netlab.cs.rpi.edu       ]
  57.